<?php //include_partial('common/flashes') ?>
<form id="patient-question-answer-comment-form-<?php echo $patientQuestionAnswerId ?>" action="<?php echo url_for('@patient_question_answer_comment_respond?answer_id=' . $patientQuestionAnswerId) ?>" method="post">
    <?php $form->setDefault("patient_question_answer_id", $patientQuestionAnswerId) ?>
    <?php echo $form->renderHiddenFields(true) ?>
    <div class="input">
        <?php echo $form["response"] ?>
        <?php if ($form["response"]->hasError()): ?>
            <?php include_partial("common/error", array("form" => $form, "field" => "response", "name_format" => isset($name_format) ? $name_format : $form->getName())) ?>
        <?php endif; ?>
    </div> 
    <button id="submit-patient-question-answer-comment-<?php echo $patientQuestionAnswerId ?>" class="button-thin-blue hide" type="submit">Comment</button>
</form>
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function(){
        // make an attempt to submit this form
        $('#submit-patient-question-answer-comment-<?php echo $patientQuestionAnswerId ?>').click(function() {
            $('#patient-question-answer-comment-form-<?php echo $patientQuestionAnswerId ?>').ajaxSubmit(function(data){ 
                if(hasForm(data))
                {         
                    $('#patient-question-answer-comment-form-holder-<?php echo $patientQuestionAnswerId ?>').html(data);
                }
                else{ 
                    $.get('/question-answer-comment/response/' + data, {}, function(commentData){   
                        $('#response-comments-<?php echo $patientQuestionAnswerId ?>').append(commentData);
                    }, 'html');
                    $('#patient-question-answer-comment-form-holder-<?php echo $patientQuestionAnswerId ?>').load('/question-answer-comment/respond/<?php echo $patientQuestionAnswerId ?>');
                    
                    $(".success-notice-1").hide(5000);
                }
            });
            return false;
        });
    });
    //]]>
</script>